//
//  NSDate+Helper.m
//  ruying
//
//  Created by yqh on 2019/3/2.
//  Copyright © 2019年 林伟钦. All rights reserved.
//

#import "NSDate+Helper.h"

@implementation NSDate (Helper)

+ (NSString *)dateStrWithFormat:(NSString *)format fromTimeStamp:(NSTimeInterval)timeStamp {
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:timeStamp];
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = format;
    
    return [formatter stringFromDate:date];
}

+ (NSDate *)dateWithFormat:(NSString *)format fromDateStr:(NSString *)dateStr {
    
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = format;
    
    return [formatter dateFromString:dateStr];
}

+ (NSString *)dateStrWithFormat:(NSString *)format fromDate:(NSDate *)date {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    formatter.dateFormat = format;
    return [formatter stringFromDate:date];
}

@end
